#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;
void test1()
{
	cout << isalpha('a') << endl;
	cout << isalpha('!') << endl;
	cout << isalpha(',') << endl;
}
class Solution {
public:
    int countSegments(string s) {
        int i = 0, count = 0;
        while (i < s.size())
        {
            int conti = 0;
            while (i < s.size()&&s[i] != ' ')
            {
                conti++;
                i++;
            }
            if (conti >= 1) ++count;
            while (i < s.size()&&s[i] == ' ')
            {
                i++;
            }
        }
        return count;
    }
};
int main()
{
    Solution s;
    cout << s.countSegments("Hello, my name is John") << endl;
	return 0;
}